package com.hhb.test;

import com.hhb.config.SpringConfig;
import com.hhb.service.UserService;
import com.hhb.service.impl.UserServiceImpl;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Demo01 {

    @Test
    public void test01(){

        //1.加载配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("bean2.xml");

        //2.获取配置创建的对象
        UserService userService = context.getBean("userServiceImpl", UserServiceImpl.class);
        userService.add();
    }

    /**
     * 使用完全注解开发
     */
    @Test
    public void test02(){

        //1.加载配置文件
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);

        //2.获取配置创建的对象
        UserService userService = context.getBean("userServiceImpl", UserServiceImpl.class);
        userService.add();
    }



}
